DXL Attribute Writes To Another Attribute


Object oAll= current
Module m = current
int iThisAbsNum = obj."Absolute Number"
int iAbsNum
int iCount= 1
string sRate
string sNum

int iOffset, iLength

for oAll in m do {                                                                                                          
    sRate= oAll ."Rate"                                                                 //Grabs string from 'Rate' attribute from current object
    iAbsNum= oAll."Absolute Number"                                    

//Grabs Absolute object number of current object
    sNum= oAll."Priority Number"                                             

//Grabs string from 'Priority Number' attribute from the current object  (***This DXL attribute is used to define the 'Priority Number' attribute)

    if(findPlainText (sRate, "High", iOffset, iLength, false)) {            

//If the 'Rate' attribute is 'High' then execute the following
        if(iAbsNum == iThisAbsNum) {                                                  

//If the current object number matches the absolute object number execute the follow
              if(intOf(sNum)==iCount)                                                          

//If the current 'Priority Number is equal to the current count simply display the count
                displayRich("\\pard " iCount "")                        
            else                                         
                
obj."Change Flag"="True"                                                  

//If the current 'Priority Number is NOT equal to the current count set the 'Change Flag' attribute to 'True' and then display the current count
                displayRich("\\pard " iCount "")                        
        }
        else iCount++

}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

I want to adjust one of my DXL attributes so that when the attribute changes to a different value it changes the value of a different attribute (shown highlighted in yellow).  Is this possible (I'm essentially creating a changebar for one particular attribute)?  I keep getting a syntax error and/or cause DOORS to crash. 

Aside:  Is there a way to only run a DXL attribute only when a certain view is active AND no filters are being used?


stevenson - Tue Feb 11 16:05:38 EST 2014

Re: DXL Attribute Writes To Another Attribute
stevenson - Tue Feb 11 16:07:53 EST 2014

Apparently you can't highlight code...

Re: DXL Attribute Writes To Another Attribute
Mathias Mamsch - Wed Feb 12 12:43:02 EST 2014

stevenson - Tue Feb 11 16:07:53 EST 2014

Apparently you can't highlight code...

Whoops I just saw, that this was totally not your question ;-) Anyway I keep that post for reference ....

I saw some green highlight flashing in your above code, when I loaded the page, but it disappeared immediately.

You can use the rtf \highlight tag to highlight stuff in DOORS DXL attributes (that do usually not support colored text). But for this to work, you need to have a color table in your attribute like in the following richtext (copied from Wordpad to DOORS)

{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}

{\colortbl ;\red255\green255\blue0;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\highlight1\lang7\f0\fs20 Hallo\highlight0\lang1031\par
}

Post this code to a DXL attirbute:

string sHeader = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1031{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}"
string s = ""; 

string sColorTable = "{\\colortbl "; 

int i; for (i = 0; i < 20; i++) { 
   int r = random(255), b = random(255), g = random(255);
   sColorTable = sColorTable ";\\red" r "\\green" g "\\blue" b ";"

    s = s "{\\highlight" i "Hallo: " r "," g "," b "}\\par" 
} 

obj.attrDXLName = richText sHeader sColorTable "}" s "}"

Maybe that helps, regards, Mathias

Re: DXL Attribute Writes To Another Attribute
Mathias Mamsch - Wed Feb 12 13:11:26 EST 2014

Ok, to your original question:

First of all you need to clarify if you mean "DXL Attribute" or "DXL Layout" ... Since in your code you are using displayRich which is a function for DXL Layouts only I assume you are doing a DXL Layout Column. If this is the case, then it is a bad idea to try to modify an attribute from a DXL layout. Secondly I hope that these comments in your code are only for reference and not in your real code. If statements with a comment between them are a bad idea:

if (true == false) // now is that a cool comment 
   print "This is not printed"

if (true == false) 
   // ouchie!
   print "This will be printed because the IF statement will use the comment"

if (true == false) { 
   // always use braces to be sure
   print "Now this will never happen!"
}

 

So coming back to the Layout DXL / Attribute DXL question. If you want a change bar you should use another way, for example a dynamic trigger or a DXL Layout / Attribute that evaluates history to check if there has been a modification made in the current session. This way you do not even need to have an attribute "Change Flag" in your module. You can store that Layout DXL in a column inside a view, so it will only be executed when you open the view. Here is an example that implements something like a change bar if the user changed the Object Text in the current Session (since he started DOORS) of course you can have another criterion (since the last baseline, since going to edit mode, etc.)

History h 

// returns the date when the user started his DOORS ..
Date dSession = session();
bool bChange = false; 

// You could also get the current edit session from the DOORS module history
// and compare this one

for h in obj do { 
   HistoryType ht = h.type 
   int historySession = h.sessionNo
   Date hDate = dateAndTime h.date;
   if (ht == modifyObject && hDate >= dSession) {
      string sAttr = h.attrName 
      if (sAttr == "Object Text") {
          bChange = true; 
          break
      }
   }
}

if (bChange) display "Changed!" 


Maybe this helps, regards, Mathias

Re: DXL Attribute Writes To Another Attribute
llandale - Wed Feb 12 15:24:13 EST 2014

MM's solution looks good, if you are trying to see if you have modified the attr value during the current session.  I'm thinking though it may be a computational hog, looping through History so very often.

I'll comment on your original code:

  • The oAll loop is unneeded, just use variable "obj".
  • It is dangerous for Attr-DXL and Layouts to modify anything (except the attr-DXL value).  If the module is opened in Read-Only mode you will get lots of write errors, and in any case is just bad ... Karma.
  • In this particular case, a Layout is superior since it will get refreshed as soon as the change is made.  Attr-DXL only gets calculated once per open module, unless you clear the values.
  • I may be tempted to have a very simple Attr-DXL that sets the value to blank; combined with a post-attr-save trigger that sets the attr-DXL to "Changed" if the change qualifies.  This works if you are after change bars for the current session only.

If you are after change bars for some time in the past, perhaps since the last Baseline (Yellow if saved, Red if changed but not yet saved), then MM's solution in an Attr-DXL (deleting the date-check) combined with a post-attr-save trigger could do the trick.

  • Enumerated Attr-DXL with values null (black), Saved (yellow), and UnSaved (red). 
  • In the Attr-DXL code, if you find a qualifying History then set the value to Saved otherwise to null.
  • In the Trigger code, if the change qualifies change the attr-DXL value to UnSaved.
  • I'm thinking the Trigger will need to query the current attr-DXL value to make sure there is one before it tries to change it.

-Louie